{'happy': 8,
'sad': 2,
'joy': 7.5,
'embarrassed': 3.6,
'restless': 4.1,
'apathetic': 3.8,
'calm': 7}
Please sign up for Google Classroom (link) if you haven’t already.
Who are you?
Name, pronouns, group you work in
What you want to get out of the class
Something that keeps you going in the winter!
Week 1 Classwork (in Classroom)
| Week | Date | Topic |
|---|---|---|
| 1* | Jan 21 | Fundamentals |
| 2 | Jan 28 | Iteration (for loops) |
| 3* | Feb 4 | Conditionals |
| 4 | Feb 11 | Functions |
| No Class | Feb 18 | Break week |
| 5 | Feb 25 | Iteration Styles |
| 6* | Mar 4 | Reference vs. Copy / Last Day of Class |
All classes are on Wednesdays from 12:00-1:30 PM PST either online, or in Arnold M1-B406 (The Data Science Lounge). Connection details will be provided. Office hours related to each class day are posted below, and the invite will be sent to you.
In class we will be going through the notebooks hosted on Google Classroom.
Classes will be recorded, and those recordings will be sent to you after each class.
Full course page here: https://hutchdatascience.org/Intermediate_Python/
We ask you to follow Participation Guidelines and Code of Conduct.
| Data type name | Data type shorthand | Examples |
|---|---|---|
| Integer | int | 2, 4 |
| Float | float | 3.5, -34.1009 |
| String | str | “hello”, “234-234-8594” |
| Boolean | bool | True, False |
There is a special None data type that shows up when nothing is returned from an expression.
List
Dataframe
Dictionary
Tuple
What does it contain?
What can it do?
This organizing structure on an object applies to pretty much all Python data types and data structures.
What does it contain?
[2, 3, 4].[ ].What can it do (methods)?
my_list.append(4) appends 4 to the last element of my_list, but does not return anything.What’s the difference between a method and a function?
What does it contain?
Attributes:
Columns of the data
.columns
.shape
.iloc[ , ] , .loc[ , ] for subsetting
What can it do (methods)?
.head()
.tail()
A quick survey to get us started: https://forms.gle/cYEWWhk1aagsefPA7
A dictionary is designed as a lookup table, organized in key-value pairs. You associate the key with a particular value, and use the key to find the value.
Data stored in nested dictionaries are often represented as JSON files. Here’s a guide on using JSON files in Python.
If you don’t want to run the risk of getting an error, you can specify a default value using the .get() method.
You can add more key-value pairs by defining it directly. If the key already exists, the mapping for that key will simply be updated.
You can create a Dataframe using a Dictionary. The key represent column names, and the value is a List containing the column’s values:
| id | case_control | measurement1 | measurement2 | measurement3 | |
|---|---|---|---|---|---|
| 0 | AAA | case | 2.5 | 0.000 | 80 |
| 1 | BBB | case | 3.5 | 0.000 | 2 |
| 2 | CCC | control | 9.0 | 0.500 | 1 |
| 3 | DDD | control | 0.1 | 0.240 | 1 |
| 4 | EEE | control | 2.2 | 0.003 | 2 |
You want to take “case_control” column of simple_df and change “case” to “experiment” and “control” to “baseline”.
This correspondence relationship can be stored in a dictionary via .replace() method for Series:
0 experiment
1 experiment
2 baseline
3 baseline
4 baseline
Name: case_control, dtype: object
You can do something similar to recode the column names of a Dataframe via the .rename() method.
Weekly Checkin (use for any questions you might have, pacing, etc.): https://forms.gle/FUsPhbs6Nu2eGbCD6